# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=unicode-character-database
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=12.1.0
pkgrel=1
pkgdesc="Unicode Character Database (mingw-w64)"
arch=(any)
license=(BSD)
url="https://www.unicode.org/"
source=("UCD-$pkgver.zip::https://www.unicode.org/Public/zipped/$pkgver/UCD.zip"
        "Unihan-$pkgver.zip::https://www.unicode.org/Public/zipped/$pkgver/Unihan.zip"
        LICENSE)
noextract=({UCD,Unihan}-$pkgver.zip)
sha512sums=('68512627ecb75520b354160216cc14622c0d5321356f03429a102f734bddf6859c4ab266ed15db177dcbffd76c97d13d90de9a4fc38b10082a0e58fe3c82cda4'
            '7fdefad078284c14a9105655d1cb4d2b0dc1c89c56effe92ffcbd5a30b325559a56d97574b6077144d7a4ed02df6e6a402a2a5360e4abc0c84bae5c589044375'
            '9ba78d68ed39745e55538180f132ff47423edb46adde7ac3e62a489870d153808bcf2db57b77e6a7cdae9b4fa03aba99cf228315b9a15be090bedef00b9e69ed')

package() {
  for _f in UCD Unihan; do
    install -Dm644 $_f-$pkgver.zip "$pkgdir${MINGW_PREFIX}/share/unicode/$_f.zip"
    bsdtar -C "$pkgdir${MINGW_PREFIX}/share/unicode" -x --no-same-owner --no-same-permissions -f $_f-$pkgver.zip
  done

#  ln -s unicode "$pkgdir${MINGW_PREFIX}/share/${_realname}"
  # FS#49938: A bunch of compatibility symlinks
  mkdir -p $pkgdir${MINGW_PREFIX}/share/unicode/ucd
  cp -r * "$pkgdir${MINGW_PREFIX}/share/unicode/ucd/"
  for _f in ${_realname} unicode-data unidata; do
    cp -r $pkgdir${MINGW_PREFIX}/share/unicode "$pkgdir${MINGW_PREFIX}/share/$_f/"
  done

  install -Dm644 LICENSE "$pkgdir${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
